package com.isoftstone.studentregistration.util;

/**
 * @author Administrator
 * @version v1.0
 * @date 2025/9/7 9:17
 */

import lombok.Data;

import java.io.Serializable;

/**
 * 封装统一返回结果
 */
@Data
public class Result <T> implements Serializable {
    private static final long serialVersionUID = 1L;
//    状态码
    private Integer code; //200成功 非200失败
    private String msg; //提示信息
    private T data; //返回数据
    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> Result<T> success() {
        return new Result<>(200,"操作成功");
    }
    public static <T> Result<T> success(T data) {
        return new Result<>(200,"操作成功",data);
    }
    public static <T> Result<T> success(String msg,T date) {
return new Result<>(200,msg,date);
    }
    public static <T> Result<T> error(Integer code,String msg) {
        return new Result<>(code,msg);
    }
    public static <T> Result<T> error(String msg) {
        return new Result<>(500,msg);
    }
}
